<?php
@session_start();
header('Content-Type:text/html; charset=utf-8');
require_once('upmklog.php');
require_once('hyang.class.php');
require_once('hyang.function.php');
require_once('./hyang/api.function.php');
require_once dirname(__FILE__).'./hyang/ControllerAbstract.php';
class Cfile extends ControllerAbstract{
	public function index()
	{	header('Content-Type:text/html; charset=utf-8');
		htmlHead('欢迎进入新版系统！');
		improt('js','newsys');
		echo '</head><body>';
		echo '<p id="navi"><a href="index.php">旧版</a> 
			<a href="file.php?sid='.crypt('logs','file').'">日志</a> 
			<a href="file.php?sid='.crypt('write','file').'">写日志</a> 
			<a href="file.php?sid='.crypt('apiStudey','file').'">API</a>
			<a href="file.php?sid='.crypt('ExcelTools','file').'">ExcelTools</a>
			<a href="file.php?sid='.crypt('createApp','file').'">系统开发</a>
			<a href="'.APP.'admin/admin.php">后台数据配置</a>
			<a href="guest.php">首页</a>
			<a href="file.php?sid='.crypt('Close','file').'">Close</a>
		</p>';
		$vtimes = json_decode($_SESSION['vtimes'],true);
		$diff = date2diff('2015-08-26',sys_date(true));
		echo '<br>您共访问该系统次数：'.$vtimes["V"];
		echo '<br>ZOTION .INC：从 2015-07-21 至 '.sys_date(true).'；共('.date2diff('2015-07-21',sys_date(true),"desc").')天。详情<i>'.($this->datediff(sys_date(true),'2015-07-21',"desc")).'</i>';
		echo '<br>交易中心：从 2015-08-26 至 '.sys_date(true).'；共('.$diff.')天,X20='.($diff*20).'。详情<i>'.($this->datediff(sys_date(true),'2015-08-26',"desc")).'</i>';
		echo improt('view','newsys.html');
		echo '</body></html>';
	}

	public function apiStudey()
	{
		header('Content-Type:text/html; charset=utf-8');
		htmlHead('API应用接入');
		improt('js','apiStudey');
		echo '</head><body>';
		echo '<div id="display">';
		echo '<a id="AreaData" href="javascript:void(0);">全国行政区域</a> ';
		echo '<a id="News" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('news','apiStudey').'">新闻</a> ';
		echo '<a id="mobliePlec" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('mobliePlec','apiStudey').'">手机归属地查询</a> ';
		echo '<a id="Idcar" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('Idcar','apiStudey').'">身份证查询</a> ';
		echo '<a id="Idcar" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('weather','apiStudey').'">天气查询</a> ';
		echo '<a id="Tuling" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('Tuling','apiStudey').'">喂，图灵</a> ';
		echo '<a id="exRate" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('exRate','apiStudey').'">汇率</a> ';
		echo '<a id="DriveTips" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('DriveTips','apiStudey').'">驾照考题</a> ';
		echo '<a id="jokes" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('jokes','apiStudey').'">笑话大全</a> ';
		echo '<a id="moviesNexs" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('moviesNexs','apiStudey').'">影视影讯</a> ';
		echo '<a id="Weixun" href="file.php?sid='.crypt('apiStudey','file').'&action='.crypt('Weixun','apiStudey').'">微信精选</a> ';
		echo '<a href="file.php">BACK</a>';
		echo '</div>';
		$action = '';
		if(isset($_GET['action']))
		{
			$action = $_GET['action'];
		}
		switch($action)
		{
			case crypt('news','apiStudey'):
				echo '<br><br><form action="javascript:void(0);" method="post"><img src="./public/image/news.png"><input type="text" id="searchIPT"> <input id="searchNews" type="submit" value="查询">';
				improt('php','news.php');
				break;
			case crypt('mobliePlec','apiStudey'):
				echo '<br><br><form action="javascript:void(0);" method="post"><img src="./public/image/Phone.png"><input type="text" id="cellphone"> <input id="searchPhone" type="button" value="查询">';
				//improt('php','mobliePlec.php');
				echo '<div id="searchPrint"></div>';
				break;
			case crypt('Idcar','apiStudey'):
				echo '<p><form action="javascript:void(0);" method="post"><img src="./public/image/id-card.png"><input type="text" id="idcard"> <input id="searchidcar" type="button" value="查询"></p>';
				echo '<div id="searchPrint"></div>';
				break;
			case crypt('weather','apiStudey'):
				echo '<p><form action="javascript:void(0);" method="post"><img src="./public/image/wearther.png"><input type="text" id="city"> <input id="searchweather" type="button" value="查询"></p>';
				echo '<div id="defualtWea"></div>';
				echo '<div id="searchPrint"></div>';
				break;
			case crypt('Tuling','apiStudey'):
				echo '<p style="font-size:0.86em;margin: 1% 0 0 50%;">快捷键：<a href="javascript:void(0);" style="text-decoration:none;">enter键</a> （发送）；<a href="javascript:void(0);" style="text-decoration:none;">空格键</a>（选择输入框）！</p>';
				echo '<p><form action="javascript:void(0);" method="post"><input type="text" id="info"> <input id="sendinfo" type="button" value="发送"></p>';
				echo '<div><p id="searchPrint"></p></div>';
				break;
			case crypt('exRate','apiStudey'):
				improt('php','exRate.php');
				break;
			case crypt('DriveTips','apiStudey'):
				echo '<p><form action="javascript:void(0);" method="post"> <select name="getCorser"><option value="" selected>选择科目<option value="1">科目一<option value="4">科目四</select> <select name="getModel"><option value="" selected>驾照类型<option value="a1">a1<option value="a2">a2<option value="b1">b1<option value="b2">b2<option value="c1">c1<option value="c2">c2</select> <select name="testType"><option value="rand" selected>随机测试<option value="order">顺序测试</select> <input id="getDirveTips" type="button" value="抽取题目"></p>';
				//improt('php','DriveTips.php');
				echo '<div style="margin:0 9% 0 4%;" id="searchPrint"></div>';
				break;
			case crypt('jokes','apiStudey'):
				echo '<p>'.Create_select(array('name'=>'jokespage','int'=>100)).'页</p>';
				echo '<p> <button name="lastJokes">最新笑话</button> <button name="lastserJokes">按时更新查询笑话</button> <button name="lastJoketu">最新趣图</button> <button name="lastserJoketu">按时更新查询趣图</button> </p>';
				//improt('php','jokes.php');
				echo '<div id="jokesAjaxPri"></div>';
				break;
			case crypt('moviesNexs','apiStudey'):
				//improt('php','moviesNexs.php');
				echo '<p><select name="moviesIndex"><option value="" selected>选择<option value="Mvname">按片名搜索电影<option value="Mvcity">输入城市搜索电影</select> <span id="CreateIptMv"></span><button name="SearthMv">查询</button></p>';
				echo '<div id="MvAjaxPri"></div>';
				break;
			case crypt('Weixun','apiStudey'):
				echo '<p>选择 ：';
				echo Create_select(array('name'=>'WeiXunpage','int'=>50));
				echo ' 页</p>';
				echo '<div id="WeixunajaxPrint" style="padding:0 0 0 7%;"></div>';
				break;
		}
		echo '</body></html>';
	}

	public function write()
	{
		header('Content-Type:text/html; charset=utf-8');
		htmlHead('编写日志');
		echo plugin('markup');
		echo plugin('tinymce');
		improt('js','write');
		improt('css','write');
		echo '</head><body>';
		echo '<p><a href="file.php">BACK</a> <a href="file.php?sid='.crypt('logs','file').'">Show</a></p>';
		improt('view','write.html');
		echo '</body></html>';
	}
	public function diswrite()
	{
		header('Content-Type:text/html; charset=utf-8');
		htmlHead('日志显示');
		improt('js','diswrite');
		echo '</head><body>';
		echo '<p><a href="file.php">BACK</a> <a href="file.php?sid='.crypt('write','file').'">Write</a></p>';
		$handle = fopen('./filesNew/text/textList(sys).data','r');
		echo '<div id="filedisplay">';
		echo fread($handle, filesize('./filesNew/text/textList(sys).data'));
		echo '</div>';
		echo '</body></html>';
	}
	public function ExcelTools()	//PHPExcel 插件应用
	{
		header('Content-Type:text/html; charset=utf-8');
		htmlHead('Excel应用工具');
		improt('js','ExcelTools');
		echo '</head><body>';
		echo '<p>
			<a href="file.php?sid='.crypt('PHPExcelDemo','file').'" target="_blank">ExcelPHP示例</a>
			<a href="file.php">IWannaComeBack</a>
		</p>';
		extension('PHPExcel');

		$this->setUser('杨华');
		//echo $this->console($this->user,'','test.js','/public/create.php');
		//$this->deleteFile('/public/create.php');
		//echo $this->info();

		//$bin = $this->str2bin('二进制文本操作：这是一个二进制文本，写到文件内。然后在还原-测试');
		//$bin = $this->asc2bin('二进制文本操作：这是一个二进制文本，写到文件内。然后在还原-测试');
		$this->setkey('foreverBrximl杨华');
		//$text = '对密文进行加密很重要！所有的软件系统都应该考虑一个安全机制，我以为.yowentima';
		$text = '我以为.yowentima1233';
		echo ($this->getkey('foreverBrximl杨华')).'<br>';
		$enc = $this->encrypt($text);
		echo $enc;
		echo '<br>';
		echo $this->decrypt($enc);
		echo '<br>';
		$bin = @pack('a','二进制文本操作：这是一个二进制文本，写到文件内。然后在还原-测试');
		$this->console($bin,'none','binfile',null,null,'r+b');
		echo $this->contents('/log/binfile');


		echo '<br>';
		print_r($_SESSION);
		echo $this->getUser();
		echo '<br>';

		$objPHPExcel = new PHPExcel();
		echo $objPHPExcel->getID();

		echo '</body></html>';
	}
	public function PHPExcelDemo()
	{
		htmlHead('PHPExcel 示例 ');
		echo '<style>
			a{text-decoration:none;padding:3px;margin:2px;}
		</style>';
		echo '</head><body>';
		$dir = './libs/libsDome/PHPExcel/Examples/';
		
		$dirData = $this -> printDir($dir,false);
		//print_r($dirData);
		echo '<div style="margin:0 0 0 25px;">';
		foreach($dirData as $v)
		{
			echo '<a href="'.$v['url'].'">'.$v['name'].'</a><br>';
		}
		echo '</div>';
		echo '</body></html>';
	}
	public function createApp()
	{
		header('Content-Type:text/html; charset=utf-8');
		htmlHead('系统开发扩展 ');
		improt('js','createApp');
		improt('css','createApp');
		echo '</head><body>';
		$dir = './hyang/app/';
		$dirApp = $this->printDir($dir,false);
		//print_r($dirApp);
		$uls = '<ul class="tree">';
		foreach($dirApp as $v)
		{
			
			$dirAppUrl = $v["url"].'/';
			$Apps = $this->printDir($dirAppUrl,false);
			if(count($Apps) > 0)
			{
				$uls .= '<li><a href="javascript:void(0);" class="firstTree" id="'.$v["name"].'">'.$v["name"].'</a><ul class="'.$v["name"].'">';
				foreach($this->printDir($dirAppUrl,false) as $vv)
				{
					$uls .= '<li><a href="javascript:void(0)" class="close" id="close:'.$v["name"].'">'.$vv["name"].'</a></li>';
				}
				if(!in_array($v["name"],array('guest'))){
					$uls .= '<li><a href="'.APP.$v["name"].'/'.$vv["name"].'">跳转至</a></li>';
				}
				$uls .= '<li><a href="javascript:void(0);" class="expApp" id="exp:'.$v["name"].'">导出</a></li>';
				if(!in_array($v["name"],array('guest','learn','admin'))){
					$uls .= '<li><a href="javascript:void(0);" class="delApp" id="del:'.$v["name"].'">删除</a></li>';
				}
				$uls .= '</ul>';
			}
			else	$uls .= '<li>'.$v["name"].'</li>';
		}
		$uls .= '<li><a href="javascript:void(0);" id="addApp">新增</a></li>
		<li><a href="javascript:void(0);">hyang框架</a></li>
		<li><a href="file.php">返回</a></li></ul>';
		echo $uls;
		improt('view','createApp.html');
		echo '</body></html>';
	}
}
?>